package drds.configuration.mvc.render;


import drds.configuration.common.Constants;
import drds.configuration.mvc.config.RouteSet;
import drds.configuration.mvc.core.ActionContext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RootRender extends Render {

    public String view;

    /**
     * 自定义路径
     */
    public RootRender(String view) {
        this.view = view;
    }

    @Override
    public void render() {
        HttpServletRequest request = ActionContext.getRequest();
        HttpServletResponse response = ActionContext.getResponse();
        try {
            request.setCharacterEncoding(Constants.characterEncoding);
            request.setCharacterEncoding(Constants.characterEncoding);
            response.setContentType("text/html; charset=" + Constants.characterEncoding);
            // /jsp/*
            if (Constants.devMode) {
                logger.debug("============================================================");
                logger.debug("跳转的url" + RouteSet.baseViewPath + view);
                logger.debug("============================================================");
            }
            request.getRequestDispatcher(RouteSet.baseViewPath + view).forward(request, response);

        } catch (Exception e) {
            throw new RenderException(e);
        }
    }

}
